home *** CD-ROM | disk | FTP | other *** search
- /* Init Mounter.c */
- /* Version 1.0a0 */
- /* */
- /* This program is intended to allow the user to execute INITs after */
- /* the startup process has been completed. */
- /* */
- /* Notes: */
- /* Currently this only works under the Finder and not Multi-Finder */
- /* -I have not had time to figure out why this is. */
- /* */
- /* Does not work with ALL INITs. So far those that don't are: */
- /* zhierDA */
- /* Shield Init */
- /* & probably others */
- /* */
- /* This code is in the public domain except where it infringes on */
- /* any copyrights and then it is not. */
- /* */
- /* Chris Faigle */
- /* AppleLink: CHRIS.FAIGLE */
-
-
- main()
- {
- int init_file_ref_num;
- int ret;
- SFReply reply_rec;
- Point where={100,100};
- SFTypeList my_list;
- Handle init_to_execute;
- long code;
- long hold;
-
- InitGraf(&thePort);
- InitFonts();
- FlushEvents( everyEvent, 0 );
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
-
- my_list[0]='INIT'; /* Inits are in INIT types */
- my_list[1]='cdev'; /* and cdev types */
- my_list[2]='xNIT'; /* This is for initCDEV users! */
- my_list[3]='xdev'; /* This is for initCDEV users! */
- InitPack(3);
- SFGetFile(where,"\p",0l,4,&my_list,0l,&reply_rec); /* Get file */
- if(!reply_rec.good) /* Did user cancel */
- {
- ExitToShell(); /* Yes-exit */
- }
- if((init_file_ref_num=OpenResFile(reply_rec.fName))==-1) /* Did open fail? */
- {
- ExitToShell(); /* Yes - exit */
- }
- init_to_execute=GetIndResource('INIT',1); /* Get the first Init resource */
- if(init_to_execute==0l) /* Get one? */
- {
- ExitToShell(); /* No - exit */
- }
- DetachResource(init_to_execute); /* Detatch the code */
- HLock(init_to_execute); /* and lock it */
- code=(long)*init_to_execute; /* Get the address of the Init to execute */
- asm /* Our sneaky little assembler routine */
- {
- movem.l d0-d7/a0-a6,-(a7) /* Save registers */
- move.l SysZone,a0 /* Move the System zone to A0 */
- _SetZone /* Make the zone the system zone */
- move.l code,a1 /* Move contents of code to a1 */
- jsr (a1) /* JSR to the start of the init code */
- move.l ApplZone,a0 /* Move the ApplZone to A0 */
- _SetZone /* Set the zone to the ApplZone */
- movem.l (a7)+,d0-d7/a0-a6 /* Restore all registers */
- }
- CloseResFile(init_file_ref_num); /* Close the resource file */
- }
-
-